package com.yuewen.test1;

import org.aspectj.lang.ProceedingJoinPoint;

/**
 * Created by liwei.b on 2017/6/20.
 */
public class AspectLogger {
    public void aroundRun(ProceedingJoinPoint joinpoint) {
        Object tmp[] = joinpoint.getArgs();
        StringBuilder sb = new StringBuilder();
        for (Object o : tmp) {
            sb.append(o.toString() + ",");
        }
        sb.deleteCharAt(sb.length() - 1);
        System.out.println(joinpoint.getTarget().getClass().getName() + "." + joinpoint.getSignature().getName() + "(" + sb.toString() + ")");
        long start = System.currentTimeMillis(), end = 0;
        try {
            joinpoint.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        end = System.currentTimeMillis();
        System.out.println("cost time=" + (end - start));
    }

    public void beforeRun() {
//        System.out.println("car is going to run before runing");
    }

    public void afterRun() {
//        System.out.println("car is running");
    }
}